
import java.util.Scanner;

public class C_1_13_8 {
    public static boolean ifOK(int x) {
        if (x == 1) {
            return false;
        }
        if (x == 2) {
            return true;
        }
        if (x % 2 == 0) {
            return false;
        }
        for (int i = 2; i * i <= x; i++) {
            if (x % i == 0) {
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int start = sc.nextInt();
        int end = sc.nextInt();
        if (start > end) {
            int tmp = start;
            start = end;
            end = tmp;
        }
        int sum = 0;
        for (int i = start; i <= end; i++) {
            if (ifOK(i))
                sum++;
        }
        System.out.println(sum);
    }
}